package com.jiaming.employee.attendance.controller;

import com.jiaming.employee.attendance.bean.pojo.Attendance;
import com.jiaming.employee.attendance.bean.vo.AddAttVO;
import com.jiaming.employee.attendance.bean.vo.DayVO;
import com.jiaming.employee.attendance.bean.vo.PageAttDataVO;
import com.jiaming.employee.attendance.bean.vo.PageAttVO;
import com.jiaming.employee.attendance.service.IAttendanceService;
import com.jiaming.employee.common.bean.vo.MyPageVO;
import com.jiaming.employee.common.response.ResultCodeEnum;
import com.jiaming.employee.common.response.ResultVO;
import com.jiaming.employee.department.service.IDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author sun
 * @create 2021-05-15-9:54
 */
@Api(value = "打卡记录API接口文档")
@RestController
@RequestMapping("/att")
public class AttendanceController {

    @Autowired
    IAttendanceService attendanceService;

    @ApiOperation(value = "分页查询打卡记录",notes = "接口描述")
    @PostMapping("/page_att")
    public ResultVO<MyPageVO<PageAttDataVO>> pageAtt(@RequestBody PageAttVO pageAttVO) {
        if (pageAttVO.getPageNum() == null || pageAttVO.getPageNum() == 0) {
            pageAttVO.setPageNum(1);
        }
        if (pageAttVO.getPageSize() == null||pageAttVO.getPageSize() == 0) {
            pageAttVO.setPageSize(5);
        }
        MyPageVO<PageAttDataVO> data = attendanceService.pageAtt(pageAttVO);
        return new ResultVO<>(ResultCodeEnum.SUCCESS,data);
    }

    @ApiOperation(value = "新增打卡记录",notes = "接口描述")
    @PostMapping("/add_att")
    public ResultVO<Attendance> addAtt(@RequestBody AddAttVO addAttVO){

        Attendance data = attendanceService.addAtt(addAttVO);

        return new ResultVO<>(ResultCodeEnum.SUCCESS,data);
    }


}
